package com.example.spring_demo.service.impl;

import com.example.spring_demo.mapper.UserMapper;
import com.example.spring_demo.service.LogService;
import com.example.spring_demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author cxx
 * @create 2020-08-20 21:56
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private LogService logService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(String name) {
        userMapper.inset(name);
        try {
            logService.insert("add log:"+name);
        } catch (Exception e) {
            e.printStackTrace ();
        }
    }
}
